﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace EIS_desktop
{
    public partial class MainForm : Form
    {
        private static Form objform;
        public MainForm()
        {
            InitializeComponent();
        }

        private bool CheckIfChild(string text)
        {
            bool nochild = true;

            foreach (Form childform in this.MdiChildren)
            {
                if (childform.MdiParent == this)
                {
                    if (childform.Name.Contains(text) == true)
                    {
                        this.ActivateMdiChild(childform);
                        nochild = false;
                        break;
                    }
                }
            }
            return nochild;
        }

        private void tsmiEmployee_Click(object sender, EventArgs e)
        {
            if (CheckIfChild("Employee") == true)
            {
                Employee objEmp = new Employee();
                objEmp.MdiParent = this;
                objEmp.Show();
            }
        }

        private void tsmiTask_Click(object sender, EventArgs e)
        {
            if (CheckIfChild("Task") == true)
            {
                Task objTask = new Task();
                objTask.MdiParent = this;
                objTask.Show();
            }
        }

        private void tsmiEmployeeCenter_Click(object sender, EventArgs e)
        {
            if (CheckIfChild("EmployeeList") == true)
            {
                EmployeeList objEmpList = new EmployeeList();
                objEmpList.MdiParent = this;
                objEmpList.Show();
            }
        }

        private void tsmiDashboard_Click(object sender, EventArgs e)
        {
            if (CheckIfChild("Dashboard") == true)
            {

                Dashboard objDashboard = new Dashboard();
                objDashboard.MdiParent = this;
                objDashboard.Show();
            }
        }

        private void payRollToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (CheckIfChild("PayCalendar") == true)
            {
                PayCalendar objPayCal = new PayCalendar();
                objPayCal.MdiParent = this;
                objPayCal.Show();
            }
        }

        private void exitToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void balancesetupMenuItem1_Click(object sender, EventArgs e)
        {
           
        }

        private void balanceToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form objform;
            
            if (CheckIfChild("BalanceSetup") == true)
            {
                objform = new BalanceSetUp();
                objform.MdiParent = this;
                objform.Show();
            }
           
        }

        private void ratesToolStripMenuItem_Click(object sender, EventArgs e)
        {

            if (CheckIfChild("Rates") == true)
            {
                objform = new Rates();
                objform.MdiParent = this;
                objform.Show();
            }
        }

        
    }
}
